# Maintainer: Renato Silva <br.renatosilva@gmail.com>

pkgname=colordiff
pkgver=1.0.19
pkgrel=1
pkgdesc='Diff wrapper with pretty syntax highlighting'
url='https://www.colordiff.org/'
license=('GPL2')
arch=('any')
depends=('diffutils' 'perl')
makedepends=(w3m)
backup=(etc/colordiffrc)
source=(${pkgname}-${pkgver}.tar.gz::"https://github.com/daveewart/colordiff/archive/v${pkgver}.tar.gz"
        002-build-fix.patch)
sha256sums=('bdfd418bf1bcf96497f9809f76565ad7e03b9eb0a1b685e91348d231ccc2cca4'
            '8d2f99a79126763babdf93ff1691c9e037a843f94afe5e631e1e7fcfae22713d')

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -p1 -i "${srcdir}/002-build-fix.patch"
  
  # xmlto txt conversion apparently does not work even with w3m
  # anyhow only man page is packaged
  sed -i "s/xmlto -vv txt colordiff.xml//" makefile
  sed -i "s/mv colordiff.txt README//" makefile
}

package() {
  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" MAN_DIR='/usr/share/man/man1' INSTALL_DIR='/usr/bin' install doc
  install -Dm644 COPYING "${pkgdir}/usr/share/licenses/${pkgname}/COPYING"
}
